//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.aidong.dao.wills;

import com.aidong.dao.wills.BaseDao;
import com.aidong.model.wills.ReportCashier;
import com.aidong.model.wills.ReportSalesByCashierID;
import java.util.Date;
import java.util.List;
import org.springframework.stereotype.Repository;

@Repository
public class ReportSalesByCashierIDDao extends BaseDao<ReportSalesByCashierID, Integer> {
    public ReportSalesByCashierIDDao() {
    }

    public List<ReportCashier> getCashierDataAll() {
        String sql = "select (a.CashierID + \'-\' + isnull(d.ChName, \'\')) as CashierName, a.ShopCode,c.ChName as ShopName,  \na.Code,b.CodeName,sum(Amount) as Amount from ReportSalesByCashierID a  \nleft join DicTranCode b on a.Code = b.TranCode \nleft join DicShopCode c on c.Code = a.ShopCode \nleft join SysUser d on d.UserCode = a.CashierID \nwhere a.ShopCode<>\'Test\' and Convert(varchar(10),a.ReportDate,111) = Convert(varchar(10),dateadd(day, -1, Getdate()),111) \ngroup by a.ShopCode,a.Code,b.CodeName,c.ChName,a.CashierID,d.ChName \norder by a.ShopCode,a.CashierID,a.code \n";
        return this.queryListBySql(ReportCashier.class, sql, new Object[0]);
    }

    public List<ReportCashier> getCashierDataByShopCode(String shopCode) {
        String sql = "select (a.CashierID + \'-\' + isnull(d.ChName, \'\')) as CashierName, a.ShopCode,c.ChName as ShopName,  \na.Code,b.CodeName,sum(Amount) as Amount from ReportSalesByCashierID a  \nleft join DicTranCode b on a.Code = b.TranCode \nleft join DicShopCode c on c.Code = a.ShopCode \nleft join SysUser d on d.UserCode = a.CashierID \nwhere Convert(varchar(10),a.ReportDate,111) = Convert(varchar(10),dateadd(day, -1, Getdate()),111) \nand a.ShopCode = :p1 \ngroup by a.ShopCode,a.Code,b.CodeName,c.ChName,a.CashierID,d.ChName \norder by a.ShopCode,a.CashierID,a.code \n";
        return this.queryListBySql(ReportCashier.class, sql, new Object[]{shopCode});
    }

    public List<ReportCashier> getCashierDataAllByDay(String serDate) {
        String sql = "select (a.CashierID + \'-\' + isnull(d.ChName, \'\')) as CashierName, a.ShopCode,c.ChName as ShopName,  \na.Code,b.CodeName,sum(Amount) as Amount from ReportSalesByCashierID a  \nleft join DicTranCode b on a.Code = b.TranCode \nleft join DicShopCode c on c.Code = a.ShopCode \nleft join SysUser d on d.UserCode = a.CashierID \nwhere a.ShopCode<>\'Test\' and Convert(varchar(10),a.ReportDate,111) = Convert(varchar(10),convert(DATETIME, :p1, 121),111) \ngroup by a.ShopCode,a.Code,b.CodeName,c.ChName,a.CashierID,d.ChName \norder by a.ShopCode,a.CashierID,a.code \n";
        return this.queryListBySql(ReportCashier.class, sql, new Object[]{serDate});
    }

    public List<ReportCashier> getCashierDataByShopCodeAndDay(String shopCode, String serDate) {
        String sql = "select (a.CashierID + \'-\' + isnull(d.ChName, \'\')) as CashierName, a.ShopCode,c.ChName as ShopName,  \na.Code,b.CodeName,sum(Amount) as Amount from ReportSalesByCashierID a  \nleft join DicTranCode b on a.Code = b.TranCode \nleft join DicShopCode c on c.Code = a.ShopCode \nleft join SysUser d on d.UserCode = a.CashierID \nwhere Convert(varchar(10),a.ReportDate,111) = Convert(varchar(10),convert(DATETIME, :p2, 121),111) \nand a.ShopCode = :p1 \ngroup by a.ShopCode,a.Code,b.CodeName,c.ChName,a.CashierID,d.ChName \norder by a.ShopCode,a.CashierID,a.code \n";
        return this.queryListBySql(ReportCashier.class, sql, new Object[]{shopCode, serDate});
    }

    public void doCashierReport(Date dateFrom, Date dateTo) {
        String sql = "{call sp_CashierReport(:p1, :p2)}";
        this.updateBySql(sql, new Object[]{dateFrom, dateTo});
    }
}
